#ifndef CComboBxH
#define CComboBxH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <StdCtrls.hpp>
#include "CtrlStd.h" //Pour TCorrectementRempliEvent
#include "Messages.h"
//---------------------------------------------------------------------------
#define ECART_LIBEL_COMBOBOX         10
//---------------------------------------------------------------------------
class PACKAGE CCustomComboBox : public TCustomComboBox
{
private:
    typedef     TCustomComboBox inherited;
    bool        FReadOnly;
    bool        FIsEcranChaine;
    bool        FObligatoire;
    AnsiString  FLibelle;
    TFont       *FLibelleFont;
    int         FSizeEsp;   // Taille entre le libelle et l'edit
    TCorrectementRempliEvent  m_pfnOnEstCorrectementRempli;
    TLabel      *LLibelle;
    int m_DroppedWidth;
    bool        FTextCompletion;
    bool        FBleuSiHint;


    void            __fastcall SetEnabled( bool bVisible);
    void            __fastcall SetLibelle( const AnsiString aLibelle);
    void            __fastcall SetLibelleFont( TFont *FFont);
    void            __fastcall SetReadOnly( bool bReadOnly);
    void            __fastcall SetSizeEsp( int iSizeEsp);
    bool            __fastcall GetEnabled();
    TFont *         __fastcall GetLibelleFont() const;
    void            __fastcall SetVisible(bool nValue);
    bool            __fastcall GetVisible(void) const;
    int             __fastcall GetItemIndex();
    void            __fastcall SetItemIndex(int iItemIndex);
    void            __fastcall SetObligatoire( bool bObligatoire);
    void            __fastcall SetBleuSiHint( bool bBleuSiHint);
    void            __fastcall SetDroppedWidth(int Largeur);
    bool            __fastcall StoredDroppedWidth();
    void            __fastcall ReplaceLibelle();
    void            __fastcall SetText( const AnsiString aText);
    AnsiString      __fastcall GetText( );

    inline void     __fastcall SetTextCompletion(bool bValue) { FTextCompletion = bValue; };

protected:
    DYNAMIC void     __fastcall KeyDown( Word &Key, Classes::TShiftState Shift);
    virtual void    __fastcall WndProc( TMessage &Message );
    void            __fastcall LibelleFontChange( TObject *Sender );
    virtual void    __fastcall ComboWndProc(Messages::TMessage &Message, HWND ComboWnd, void * ComboProc);
    DYNAMIC void    __fastcall Change(void);

public:
  __fastcall CCustomComboBox(TComponent* Owner);
    virtual __fastcall ~CCustomComboBox();
    virtual bool __fastcall EstCorrectementRempliDefault( void);

    __property int          ItemIndex = {read=GetItemIndex,    write=SetItemIndex,   default = -1}; //Cette ligne doit OBLIGATOIREMENT être déclaré après la propriété Items dans la DFM pour que l'ItemIndex pointe sur une chaîne déjà initialisé lors du chargement
    __property AnsiString   Libelle         = { read=FLibelle,      write=SetLibelle                        };
    __property TFont        *LibelleFont    = { read=GetLibelleFont,write=SetLibelleFont};
    __property bool         Obligatoire     = { read=FObligatoire,  write=SetObligatoire, default = false };
    __property bool         ReadOnly        = { read=FReadOnly,     write=SetReadOnly,  default = false     };
    __property int          SizeEspace      = { read=FSizeEsp,      write=SetSizeEsp,   default = ECART_LIBEL_COMBOBOX };
    __property bool         Visible         = { read=GetVisible,    write=SetVisible, default = true      };
    __property bool         BleuSiHint     = { read=FBleuSiHint,  write=SetBleuSiHint, default = false };

__published:
    __property              Color;
    __property bool         Enabled         = { read=GetEnabled,    write=SetEnabled,   default = true      };
    __property bool         IsEcranChaine   = { read=FIsEcranChaine,    write=FIsEcranChaine,   default = true   };
    __property              ParentColor     = { stored = false}; //Propriété à supprimer (stored = false ajouté le 09/05/2005)
    __property              Text            = { read=GetText,    write=SetText};
    __property bool         TextCompletion  = { read=FTextCompletion, write=SetTextCompletion, default = false };

    // Evenements
    __property TCorrectementRempliEvent OnEstCorrectementRempli = { read = m_pfnOnEstCorrectementRempli, write = m_pfnOnEstCorrectementRempli};
    __property int DroppedWidth = {read = m_DroppedWidth,write = SetDroppedWidth,default = 0, stored = StoredDroppedWidth};
};

class PACKAGE_CTRLSTD CComboBox : public CCustomComboBox
{
__published:
    __property              Anchors;
    __property              BleuSiHint;
    __property              CharCase;
    __property              DropDownCount;
    __property              DroppedDown;
    __property              Enabled;
    __property              Font;
    __property              HelpContext;
    __property              Hint;
    __property              IsEcranChaine;
    __property              ItemHeight;
    __property              Items;
    __property              ItemIndex;
    __property              Libelle;
    __property              *LibelleFont;
    __property              MaxLength;
    __property              Obligatoire;
    __property              ParentFont;
    __property              ParentShowHint;
    __property              PopupMenu;
    __property              ReadOnly;
    __property              ShowHint;
    __property              SizeEspace;
    __property              Sorted;
    __property              Style;
    __property              TabOrder;
    __property              TabStop;
    __property              Text;
    __property              Visible;
    __property              TextCompletion;

    // Evenements
    __property OnDrawItem;
    __property OnDropDown;
    __property OnChange;
    __property OnStartDrag;
    __property OnDragDrop;
    __property OnDragOver;
    __property OnEndDrag;
    __property OnKeyDown;
    __property OnKeyPress;
    __property OnKeyUp;
    __property OnEnter;
    __property OnExit;
    __property OnMouseDown;
    __property OnMouseMove;
    __property OnMouseUp;
    __property OnClick;
    __property OnDblClick;
    __property OnMeasureItem;
    __property OnEstCorrectementRempli;

public:
    __property              EditHandle;
    __property              ListHandle;
    virtual bool __fastcall EstCorrectementRempliDefault( void);

public:
    __fastcall CComboBox(TComponent* Owner);
};

//---------------------------------------------------------------------------
#endif
